/*
 * Replace all of this with GtkBuilder. Then create a UIManager to handle 
 * accels, action groups, toolbars, menu items, etc. This should define events
 * and signals and delegate the backend labor to objects of the defined classes 
 * (Track, Playlist, XesamClient, etc.) in the accompanying files. 
 */

using GLib;
using Gtk;

public class MainWindow : Window {
	construct {
		destroy += Gtk.main_quit;
		title = "Hum";
		
		// Create the primary box. //
		var windowVBox = new VBox (false, 0);
		add (windowVBox);
		
		// Create the toolbar. //
		var toolbar = new Toolbar ();
		var previousButton = new ToolButton.from_stock ("gtk-media-previous");
		var playButton = new ToggleToolButton.from_stock ("gtk-media-play");
		var stopButton = new ToolButton.from_stock ("gtk-media-stop");
		var nextButton = new ToolButton.from_stock ("gtk-media-next");
		
		playButton.toggled += btn => {
			if (btn.get_active ()) {
				btn.set_stock_id ("gtk-media-pause");
				title = "Hum";
			}
			else {
				btn.set_stock_id ("gtk-media-play");
				title = "Hum (Paused)";
			}
		};
		
		toolbar.insert (previousButton, 0);
		toolbar.insert (playButton, 1);
		toolbar.insert (stopButton, 2);
		toolbar.insert (nextButton, 3);
		
		windowVBox.pack_start (toolbar, false, true, 0);
		
		// Create the track title and progress labels. //
		var labelHBox = new HBox (true, 5);
		var trackLabel = new Label ("");
		var durationLabel = new Label ("0:23 of 22:18");
		
		trackLabel.use_markup = true;
		trackLabel.set_markup ("<b><big>Not playing</big></b>");
		trackLabel.xalign = 0.0;
		durationLabel.xalign = 1.0;
		
		labelHBox.pack_start (trackLabel, false, true, 5);
		labelHBox.pack_start (durationLabel, false, true, 5);
		
		windowVBox.pack_start (labelHBox, false, true, 5);
		
		// Create the track slider. //
		var slider = new HScale.with_range (0.0, 1000000.0, 1.0);
		slider.draw_value = false;
		
		windowVBox.pack_start (slider, false, true, 5);
	}

	static int main (string[] args) {
		Gtk.init (out args);

		var sample = new MainWindow ();
		sample.show_all ();

		Gtk.main ();
		return 0;
	}
}

